{include file="header/index" /}
<meta charset="UTF-8">
	<body>
		<div class="container bgwhite">
			<h2 class="container-title ">数据库还原</h2>
			<div class="table-responsive mt20">
				<table class="table table-bordered">
					<thead>
						<tr>
							<th>备份名称</th>
							<th>卷数</th>
							<th>压缩</th>
							<th>数据大小</th>
							<th>备份时间</th>
							<th>操作</th>	
						</tr>
					</thead>
					<tbody>
						
					{foreach $data as $key => $vo}
						<tr>
							<td>{$vo.time|date='Ymd-His',###}</td>
							<td>{$vo.part}</td>
							<td>{$vo.compress}</td>
							<td>{$vo.size|format_bytes}</td>
							<td>{$key}</td>
							<td>
								 <a class="operatOptimi db-import" href="{:url('revert',['time'=>$vo['time']])}">还原</a>
								 <a class="operatRepair" onclick="del(this,{$vo.time})">删除</a>
								<!-- <button class="operatOptimi" onclick="revert(this);" data-href="{:url('revert',['time'=>$vo['time']])}">还原</button> -->
								<!-- <button class="operatRepair">删除</button> -->
							</td>
						</tr>
					{/foreach}	
						
					</tbody>
				</table>
			</div>
		</div>
	</body>
	<script>
	$(function () {
	    
        $(".db-import").click(function () {
            var self = this, status = ".";
            $.get(self.href, success, "json");
            window.onbeforeunload = function () { return "正在还原数据库，请不要关闭！";};
            return false;
            function success(data) {
                if (data.code) {
                    if (data.data.gz) {
                        data.msg += status;
                        if (status.length === 5) {
                            status = ".";
                        } else {
                            status += ".";
                        }
                    }
                    $(self).parent().prev().text(data.msg);
                    if (data.data.part) {
                        $.get(self.href, {"part": data.data.part, "start": data.data.start}, success, "json");
                    } else {
                        window.onbeforeunload = function () {return null;};
                    }
                } else {
                    layer.alert(data.msg,0);
                }
            }
        });
    });
	
	//删除
	function del(obj,time){
		top.layer.confirm('你确定要删除吗?', {
			  btn: ['确定','取消'] //按钮
			},function(){
				$.get("{:url('Data/del')}",{time:time},function(data){
					if(data.code == 1){
						$(obj).parents('tr').remove();
						top.layer.msg(data.msg, {icon: 1});
					}else{
						top.layer.msg(data.msg, {icon: 2});
					}
				},'json');
			});	
	}
	
	

	
	
	
	</script>
	
	
	
	
	
</html>
